package com.code.lightning.common.convert;

import com.code.lightning.common.api.BasicEntityConvert;
import com.code.lightning.common.enums.LightingCore;
import lombok.extern.slf4j.Slf4j;

/**
 * 转换器工厂类
 * @author LGX_TvT
 * @date 2021-01-15 22:45
 */
@Slf4j
public class EntityConvertFactory {

    private static EntityConvertFactory factory = new EntityConvertFactory();

    private EntityConvertFactory() {
    }

    /**
     * 获取工厂实例
     * @return EntityConvertFactory
     */
    public static EntityConvertFactory getInstance() {
        return factory;
    }

    /**
     * 创建转换器
     * @param lang 转换器类型
     * @return BasicEntityConvert 转换器
     */
    public BasicEntityConvert createConvert(String lang) {
        if (LightingCore.LanguageCategory.JAVA.getValue().equals(lang.toUpperCase())) {
            return new JavaEntityConvert();
        }
        log.error("can not find convert by {}", lang);
        return null;
    }

}
